﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Unity.Errors.root;
using System.Windows.Forms;

namespace Unity.Errors.types
{
    public class TCustomError
    {
        #region ctors
        public TCustomError(bool debugOn)
        {
            _DebugOn = debugOn;
        }
        #endregion

        #region properties
        private bool _DebugOn;
        #endregion

        #region overriden methods
        public void Assert(bool expression, TErrorInfo ei, string msg, params object[] args)
        {
            if (!_DebugOn)
                return;
            if (!expression)
            {
                string eiPosix =
                    String.Format("Error Encountered!\n{0}", ei.ToString());
                MessageBox.Show(String.Format(eiPosix + msg, args));
                throw new ApplicationException();
            }
        }
        #endregion
    }
}
